package com.hbnu.test.www.Exception_Test;

public class Solution {

    public int[] invertedArray(int n , int k) throws Exception {
        // -- write your code here --
        if(k <= n){
            int[]arr = new int[n];
            for (int i = 0; i < n; i++) {
                if(k!=0){
                    arr[i] = k;
                    k--;
                }
                else{
                    arr[i] = 0;
                }
            }
            return arr;
        }
        else{
            throw new Exception("The length of parameter k is not legal.");
        }

    }
}